# 请判断一个链表是否为回文链表。

# 示例 1:

# 输入: 1->2
# 输出: false
# 示例 2:

# 输入: 1->2->2->1
# 输出: true


class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class Solution:
    def isPalindrome(self, head):
        """
        :type head: ListNode
        :rtype: bool
        """
        if not head:
            return True
        res = []
        node = head
        while node:
            res.append(node.val)
            node = node.next
        n = len(res)
        for i in range(n):
            r = n-1-i
            if i < r:
                if res[i] != res[r]:
                    return False
            else:
                return True
        return True
